<template>
	<view>
		<u-navbar title="反馈意见" :autoBack="true" rightText="添加" @rightClick="rightClick">
		</u-navbar>
		<uni-list v-if="list.length">
			<uni-list-item v-for="(item,index) in list" :key="index" :ellipsis="1" :title="item.vcTitle" showArrow
				rightText="查看详情" @click="detail(index)" link></uni-list-item>

		</uni-list>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				parentId: 0,
				list: []
			}
		},
		onLoad() {
			this.getUserInfo();
		},
		onShow() {},
		methods: {
			rightClick() {
				let _this = this;
				uni.navigateTo({
					url: 'add/add?parentId=' + _this.parentId
				})
			},
			getUserInfo() {
				let _this = this;
				let opts = {
					url: 'UserInfo.shtml'
				};
				let param = {
					token: uni.getStorageSync('userInfo').token
				};
				_this.$http.httpRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == '200') {
							_this.parentId = res.data.data.user_id;
							_this.getData();
						} else {
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
					},
					error => {
						console.log(error);
					}
				);
			},
			getData() {
				let _this = this;

				let opts = {
					url: 'Message/SearchMessage.shtml'
				};
				let param = {
					jz_id: _this.parentId
				};
				_this.$http.httpRequest(opts, param).then(
					res => {
						console.log(2);
						console.log(res.data);
						if (res.data.code == '200') {
							_this.list = res.data.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
					},
					error => {
						console.log(error);
					}
				);
			},
			detail(e) {
				console.log(e)
				let _this = this;
				uni.navigateTo({
					url: 'detail/detail?id=' + _this.list[e].longId + "&title=" + _this.list[e].vcTitle +
						"&content=" + _this.list[e].textContent

				})
			}
		}
	}
</script>

<style>

</style>
